-- GENERATED SPELL FOR [Ancient Shadowmoon Spirit] --


function spell0_21797(pUnit, Event) --@Death and Decay,n/a--
pUnit:FullCastSpellOnTarget(37788,pUnit:GetMainTank ())
pUnit:RegisterEvent('Sorts_21797', 22000, 1)
end

function spell1_21797(pUnit, Event) --@Haste,Self--
pUnit:FullCastSpellOnTarget(37728,pUnit)
pUnit:RegisterEvent('Sorts_21797', 598, 1)
end

function spell2_21797(pUnit, Event) --@Touch of Darkness,Heal--
pUnit:FullCastSpellOnTarget(37727,pUnit)
pUnit:RegisterEvent('Sorts_21797', 579, 1)
end

function spell3_21797(pUnit, Event) --@Unholy Armor,Self--
pUnit:FullCastSpellOnTarget(37729,pUnit)
pUnit:RegisterEvent('Sorts_21797', 15000, 1)
end

function Sorts_21797(pUnit, Event)
local choix_sorts_21797 = math.random(0, 3)
if choix_sorts_21797 == 0 then
pUnit:RegisterEvent('spell0_21797', 1, 1)
end
if choix_sorts_21797 == 1 then
pUnit:RegisterEvent('spell1_21797', 1, 1)
end
if choix_sorts_21797 == 2 then
pUnit:RegisterEvent('spell2_21797', 1, 1)
end
if choix_sorts_21797 == 3 then
pUnit:RegisterEvent('spell3_21797', 1, 1)
end
end

function mob21797_Action(pUnit, Event)
pUnit:RegisterEvent('Sorts_21797', math.random(1500, 3000), 1)
end

function mob21797_Leave(pUnit, Event)
--pUnit:RemoveEvents();--
end

function mob21797_Kill(pUnit, Event)
--pUnit:RemoveEvents();--
end

function mob21797_Die(pUnit, Event)
pUnit:RemoveEvents();
end

RegisterUnitEvent(21797, 1, 'mob21797_Action')
RegisterUnitEvent(21797, 2, 'mob21797_Leave')
RegisterUnitEvent(21797, 3, 'mob21797_Kill')
RegisterUnitEvent(21797, 4, 'mob21797_Die')
